
// Copyright (C) 2007 Richard Uhler
// This file is part of Esiply.
//
// Esiply is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, Version 2,
// as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

#ifndef _INTERNAL_FUNCTION_H_
#define _INTERNAL_FUNCTION_H_

#include "Function.h"
#include "Value.h"

// An internal function is a Function which is implemented
// in c. That is, it has a function pointer which it
// uses to execute itself.

// internal_call_function_t 
// internal_construct_function_t are the function pointer types
// of c functions for implementation.
class Scope;

typedef Value* (*internal_call_function_t)(Value* this_obj, List* args);
typedef Value* (*internal_construct_function_t)(List* args);

class InternalFunction : public Function
{
public:
    // call or construct may be NULL
    InternalFunction(internal_call_function_t call,
            internal_construct_function_t construct, int params);

    virtual Value* call(Scope* scope, Value* this_obj, List* args);
    virtual Value* construct(List* args);

private:
    internal_call_function_t m_call;
    internal_construct_function_t m_construct;
};

#endif//_INTERNAL_FUNCTION_H_

